package com.shrct.businessprocess.project.impl;

import com.shrct.businessprocess.project.RCProject;
import com.shrct.businessprocess.project.RCProjectMoney;
import com.shrct.businessprocess.project.RCProjectServiceDeliver;
import com.shrct.businessprocess.project.RCProjectType;
import com.shrct.businessprocess.project.impl.RCProjectTypeExtensionImpl;
import com.shrct.businessprocess.project.proxy.RCProjectServiceDeliverProxy;
import edu.fudan.mylang.pf.IObjectFactory;
import java.util.Date;
import javax.persistence.DiscriminatorValue;
import javax.persistence.Entity;
import org.eclipse.xtext.xbase.lib.DoubleExtensions;
import org.eclipse.xtext.xbase.lib.Procedures.Procedure1;

@Entity
@DiscriminatorValue("RCPROJECTSERVICEDELIVER_TYPE")
public class RCProjectServiceDeliverImpl extends RCProjectTypeExtensionImpl implements RCProjectServiceDeliver {
  public RCProjectServiceDeliverImpl() {
    super();
  }
  
  private Boolean delivered = Boolean.valueOf(false);
  
  public Boolean getDelivered() {
    return this.delivered;
  }
  
  public RCProjectServiceDeliver setDelivered(final Boolean delivered) {
    this.delivered = delivered;
    return this;			
    
  }
  
  private Date confirmDate;
  
  public Date getConfirmDate() {
    return this.confirmDate;
  }
  
  public RCProjectServiceDeliver setConfirmDate(final Date confirmDate) {
    this.confirmDate = confirmDate;
    return this;			
    
  }
  
  public void initType() {
    this.setType(RCProjectType.serviceDeliver);
  }
  
  public Double calcPercent() {
    double _xifexpression = (double) 0;
    if ((this.delivered).booleanValue()) {
      _xifexpression = 1d;
    } else {
      _xifexpression = 0d;
    }
    return Double.valueOf(_xifexpression);
  }
  
  public Double calcTotalIncome() {
    RCProject _project = this.getProject();
    RCProjectMoney _totalContractAmount = _project.getTotalContractAmount();
    Double _hostAmount = _totalContractAmount.toHostAmount();
    Double _calcPercent = this.calcPercent();
    double _multiply = DoubleExtensions.operator_multiply(_hostAmount, _calcPercent);
    return Double.valueOf(_multiply);
  }
  
  public static RCProjectServiceDeliver create(final IObjectFactory objectFactory) {
    com.shrct.businessprocess.project.RCProjectServiceDeliver rCProjectServiceDeliver = new com.shrct.businessprocess.project.impl.RCProjectServiceDeliverImpl(
    );
    objectFactory.create(rCProjectServiceDeliver);
    return rCProjectServiceDeliver;			
    
  }
  
  public static RCProjectServiceDeliver createRCProjectServiceDeliverImpl(final IObjectFactory objectFactory, final Procedure1<RCProjectServiceDeliver> init) {
    com.shrct.businessprocess.project.RCProjectServiceDeliver rCProjectServiceDeliver = new com.shrct.businessprocess.project.impl.RCProjectServiceDeliverImpl(
    );
    objectFactory.create(rCProjectServiceDeliver);
    init.apply(rCProjectServiceDeliver);
    
    return rCProjectServiceDeliver;			
    
  }
  
  public RCProjectServiceDeliverProxy toProxy() {
    com.shrct.businessprocess.project.proxy.RCProjectServiceDeliverProxy proxy = new com.shrct.businessprocess.project.proxy.RCProjectServiceDeliverProxy();
    proxy.setId(this.getId());
    if(this instanceof edu.fudan.mylang.pf.INamedModelObject){
    	proxy.setName(((edu.fudan.mylang.pf.INamedModelObject)this).getEntityName());
    }
    return proxy;
    
  }
}
